#include <bits/stdc++.h>
using namespace std;
const int maxn = 50+5,maxl = 1e3+5, INF = 0x3f3f3f3f;
int d[maxl][maxl], P[maxn];
int L, N;

int D(int l, int r){
    int & ans = d[l][r];
    if(ans) return ans;
    ans = INF;
    bool find = false;
    for (int i = l+1; i <= r-1; ++i) {
        ans = min(ans, D(l, i) + D(i, r) + P[r]-P[l]), find = true;
    }
    if(!find) ans = 0;
    return ans;
}

int main() {
//    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    while(cin >> L && L){
        memset(d, 0, sizeof(d));
        cin >> N;
        for (int i = 1; i <= N; ++i) {
            cin >> P[i];
        }
        P[N+1] = L;
        printf("The minimum cutting is %d.\n", D(0, N+1));
    }
    return 0;
}